package acwing.前缀和与差分;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        int n,m;
        int[] a=new int[100010];
        int[] s=new int[100010];
        String[] strings=reader.readLine().split(" ");
        n=Integer.parseInt(strings[0]);
        m=Integer.parseInt(strings[1]);
        String[] strings1=reader.readLine().split(" ");
        for (int i = 1; i <=n; i++) {
            a[i]=Integer.parseInt(strings1[i-1]);
        }
        for (int i = 1; i <=n; i++) {
            s[i]=s[i-1]+a[i];
        }
        while ((m--)>0){
            int l,r;
            String[] strings2=reader.readLine().split(" ");
            l=Integer.parseInt(strings2[0]);
            r=Integer.parseInt(strings2[1]);
            System.out.println(s[r]-s[l-1]);
        }
    }
}
